#include <cstdio>
#include <cstring>
const int N = 1010;
int cnt, n, m, k;
int match[N], heads[N];
bool vis[N], vl[N], vr[N], nomat[N];

struct Edge {
	int v, nxt;
} e[1000010];
inline void add(int u, int v) {
	e[++cnt].nxt = heads[u];
	heads[u] = cnt;
	e[cnt].v = v;
}

bool dfs(int x) {
	for (int i = heads[x]; i; i = e[i].nxt) {
		int v = e[i].v;
		if (!vis[v]) {
			vis[v] = true;
			if (!match[v] || dfs(match[v])) {
				match[v] = x;
				nomat[x] = true;
				return true;
			}
		}
	}
	return false;
}

void dfs2(int x) {
	vl[x] = true;
	for (int i = heads[x]; i; i = e[i].nxt) {
		if (match[e[i].v] && !vl[match[e[i].v]] && !vr[e[i].v]) {
			vr[e[i].v] = true;
			dfs2(match[e[i].v]);
		}
	}
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
	freopen("testdata.in", "r", stdin);
	freopen("testdata.out", "w", stdout);
#endif
#ifndef LOCAL
	freopen("UVA11419.in", "r", stdin);
	freopen("UVA11419.out", "w", stdout);
#endif
#endif
	while (true) {
		memset(e, 0, sizeof(e));
		memset(nomat, 0, sizeof(nomat));
		memset(vl, 0, sizeof(vl));
		memset(vr, 0, sizeof(vr));
		memset(match, 0, sizeof(match));
		memset(heads, 0, sizeof(heads));
		cnt = 0;
		scanf("%d%d%d", &n, &m, &k);
		if (n == 0 || m == 0 || k == 0) break;
		int t1, t2;
		for (int i = 1; i <= k; ++i) {
			scanf("%d%d", &t1, &t2);
			add(t1, t2);
		}
		int ans = 0;
		for (int i = 1; i <= n; ++i) {
			memset(vis, 0, sizeof(vis));
			if (dfs(i)) ++ans;
		}
		printf("%d ", ans);
		for (int i = 1; i <= n; ++i) {
			if (!nomat[i]) dfs2(i);
		}
		for (int i = 1; i <= n; ++i) {
			if (!vl[i]) {
				printf("r%d ", i);
			}
		}
		for (int i = 1; i <= m; ++i) {
			if (vr[i]) {
				printf("c%d ", i);
			}
		}
		puts("");
	}
	return 0;
}